/*
 * Group 3, User Interface Programming II (vt11)
 * Pooya | Flora | Monica | Can
 */
package vical.model;

/**
 * The class to store value and display string of priority
 * 
 * @author Can
 */
public class Priority {

    public static final String HIGH = "high";
    public static final String MEDIUM = "medium";
    public static final String LOW = "low";
    private String priority;

    public Priority(String priority) {
        this.priority = priority;
    }

    public String getPriority() {
        return priority;
    }

    public void setPriority(String priority) {
        this.priority = priority;
    }

    public String getDisplayPriority() {
        if (this.priority.equals(HIGH)) {
            return Internationalization.getString("cell.priority.high");
        } else if (this.priority.equals(MEDIUM)) {
            return Internationalization.getString("cell.priority.medium");
        } else if (this.priority.equals(LOW)) {
            return Internationalization.getString("cell.priority.low");
        }
        return "";
    }

    @Override
    public String toString() {
        return getDisplayPriority();
    }

    // return 0 if equal, negative if p2>p1, positive if p2<p1
    public int compareTo(Priority p2) {
        if (this.getPriority().equals(p2.getPriority())) {
            return 0;
        }
        if (this.getPriority().equals(LOW)) {
            return -1;
        }
        if (this.getPriority().equals(HIGH)) {
            return 1;
        }
        if (p2.getPriority().equals(LOW)) {
            return 1;
        } else {
            return -1;
        }
    }
}
